home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Python 1.3.3 / Python 133 68K / Demo / www / huntlook.py < prev    next >
Text File  |  1996-05-20  |  854b  |  40 lines

  1. #! /usr/local/bin/python
  2.  
  3. import sys
  4. import string
  5. import dbm
  6.  
  7. def main():
  8.     dbnames = ['done', 'todo', 'stop', 'errs', 'othr']
  9.     dbd = {}
  10.     for dbname in dbnames[:]:
  11.         try:
  12.             dbd[dbname] = dbm.open('@' + dbname, 'r', 0)
  13.         except dbm.error, msg:
  14.             print '@' + dbname, ':', msg
  15.             dbnames.remove(dbname)
  16.     for addr in sys.argv[1:]:
  17.         if addr in dbnames:
  18.             db = dbd[addr]
  19.             print 'Database', addr, 'has', len(db), 'Entries'
  20.             for key in db.keys():
  21.                 print key
  22.                 result = db[key]
  23.                 parts = string.splitfields(result, '\t')
  24.                 label = 'from'
  25.                 for p in parts:
  26.                     print label, p
  27.                     label = ' '*len(label)
  28.             continue
  29.         print addr
  30.         for dbname in dbnames:
  31.             db = dbd[dbname]
  32.             if db.has_key(addr):
  33.                 result = db[addr]
  34.                 parts = string.splitfields(result, '\t')
  35.                 for p in parts:
  36.                     print dbname, p
  37.                     dbname = ' '*len(dbname)
  38.  
  39. main()
  40.